home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
scope
/
101-125
/
scopedisk106
/
snag
/
snag.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-19
|
4KB
|
142 lines
/* SNAG by Paul Falstad */
struct Library *GfxBase,*IntuitionBase;
main()
{
static struct NewScreen NewScreen = {
0,0,320,200,1,0,0,0,CUSTOMSCREEN,0,0,0,0 };
static char buf[90],pbuf[10];
static int daynum[12] = { 31,29,31,30,31,30,31,31,30,31,30,31 };
FILE *in;
int t0,t1,t2,ot0,ot1,ot2;
unsigned long tt,tim;
long y = 20,loc;
struct Screen *Screen;
GfxBase = OpenLibrary("graphics.library",0L);
IntuitionBase = OpenLibrary("intuition.library",0L);
if (in = fopen("s:snag.dat","r+"))
while (!feof(in))
{
tim = time(0L);
loc = ftell(in);
fgets(buf,90,in);
if (*buf == '*')
break;
if (*buf == ';')
continue;
ot0 = t0 = (buf[41]-'0')*10+buf[42]-'0';
ot1 = t1 = (buf[44]-'0')*10+buf[45]-'0';
ot2 = t2 = (buf[47]-'0')*10+buf[48]-'0';
daynum[1] = (t2 % 4) ? 28 : 29;
if (t2 == 50)
{
/* if ((tim % 86400) > 79200)
tt = 0;
else */ /* doesn't work anymore */
tim = 0;
}
else
{
for (tt = 0, t2--; t2 >= 78; t2--)
{
if (t2 % 4)
tt += 365L*24L*3600L;
else
tt += 366L*24L*3600L;
}
for (t0--; t0 >= 1; t0--)
tt += daynum[t0-1]*24L*3600L;
tt += 24L*3600L*(t1-1);
}
if (tt+(3600*3) < tim) /* wait till 3 am */
{
if (y == 20)
{
Screen = OpenScreen(&NewScreen);
sprintf(pbuf,"%6lx",Screen);
Move(&Screen->RastPort,0L,197L);
Text(&Screen->RastPort,pbuf,6L);
}
Move(&Screen->RastPort,0L,(long) (y += 10));
Text(&Screen->RastPort,buf,40L);
if (buf[49] == '*')
{
ot1 += 7;
if (ot1 > daynum[ot0-1])
{
ot1 -= daynum[ot0-1];
if (++ot0 > 12)
{
ot0 -= 12;
ot2++;
}
}
fseek(in,loc,0);
sprintf(&buf[41],"%02d-%02d-%02d*",ot0,ot1,ot2);
fwrite(buf,50,1,in);
fseek(in,loc+51,0);
}
if (buf[49] == ']')
{
ot1++;
if (ot1 > daynum[ot0-1])
{
ot1 -= daynum[ot0-1];
if (++ot0 > 12)
{
ot0 -= 12;
ot2++;
}
}
fseek(in,loc,0);
sprintf(&buf[41],"%02d-%02d-%02d]",ot0,ot1,ot2);
fwrite(buf,50,1,in);
fseek(in,loc+51,0);
}
if (buf[49] == '!')
{
ot1 += 14;
if (ot1 > daynum[ot0-1])
{
ot1 -= daynum[ot0-1];
if (++ot0 > 12)
{
ot0 -= 12;
ot2++;
}
}
fseek(in,loc,0);
sprintf(&buf[41],"%02d-%02d-%02d!",ot0,ot1,ot2);
fwrite(buf,50,1,in);
fseek(in,loc+51,0);
}
if (buf[49] == '&')
{
ot2++;
fseek(in,loc,0);
sprintf(&buf[41],"%02d-%02d-%02d&",ot0,ot1,ot2);
fwrite(buf,50,1,in);
fseek(in,loc+51,0);
}
if (buf[49] == '^')
{
ot0++;
if (ot0 > 12)
{
ot0 = 1;
ot2++;
}
fseek(in,loc,0);
sprintf(&buf[41],"%02d-%02d-%02d^",ot0,ot1,ot2);
fwrite(buf,50,1,in);
fseek(in,loc+51,0);
}
}
}
fclose(in);
CloseLibrary(IntuitionBase);
CloseLibrary(GfxBase);
}